/**
 * zhanjun
 */

$(function() {
	/*
	 * 初始化类型下拉框
	 */
	$("#roleType")[0].options.length = 0;
	$.getJSON("../dict/ser_getdict.do?systemKey=USERSAPP&tbaleKey=COMMON&fieldKey=TYPE", function(data) {
	
		$.each(data.options, function(i) {
			$("<option value='" + data.options[i].key + "'>"+ data.options[i].value + "</option>").appendTo("#roleType");
		});
	});
	
	$("#btn_reset").click(function() {
		document.getElementById("dataform").reset();

		location.href='role-admin.html';
		
	});
	/*
	 * 保存事件
	 */

	$("#btn_submit").click(function() {
		var postdata = $('#dataform').serialize();
		alert(postdata);
		if($('#dataform').form('validate')){		
			$.ajax({
				type : "POST",
				url : "../role/ser_save.do",
				data : postdata,
				success : function(msg) {
					alert(msg);
					document.getElementById("dataform").reset();					
				}
			});
		}
	});

});
